/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       ai_value.h

	$NoKeywords: $

 ************************************************************************/

#ifndef _HDR_AI_VALUE_FUNCS_H
#define _HDR_AI_VALUE_FUNCS_H

class t_artifact;
class t_creature_array;
class t_creature_stack;
class t_hero;
class t_player;
class t_single_use_object;
class t_qualified_adv_object_type;

enum t_artifact_slot;
enum t_artifact_type;
enum t_offense_type;
enum t_spell;
enum t_town_type;

#include "artifact.h"
#include "skill.h"

struct t_artifact_value_query
{
	typedef std::vector< t_artifact_slot > t_slot_vector;

	t_artifact_value_query();
	t_artifact_value_query( t_creature_array const* _array, t_creature_stack const* _stack,
							t_artifact_type _artifact );

	t_creature_array const*		array; 
	t_artifact					artifact;
	t_creature_stack const*		stack;

	float						existing_value;
	t_slot_vector				displacement;
	bool						hoard;
	float						new_value;

	float						get_value() const;
};

inline float t_artifact_value_query::get_value() const
{
	return new_value - existing_value;
}

float ai_average_skill_value( float cost, t_skill_type type_low, t_skill_type type_high, t_creature_array const* array, t_single_use_object const* object = NULL );
float ai_average_of_upgradable_skill_value( t_hero const* hero, float cost, t_skill_type type_low, t_skill_type type_high, t_creature_array const* array, t_single_use_object const* object );
float ai_average_of_upgradable_skill_value( float cost, t_skill_type type_low, t_skill_type type_high, t_creature_array const* array, t_single_use_object const* object = NULL );

float ai_bonus_for_generalship_skills( t_creature_array const* array, bool include_dead_heroes = false );
float ai_bonus_for_luck( int value );
float ai_bonus_for_luck_change( int before, int after );
float ai_bonus_for_morale( int value );
float ai_bonus_for_morale_change( int before, int after );

void ai_calculate_artifact_level_values(t_player* player);

int ai_get_hero_offense( t_creature_stack const* stack, t_offense_type type );

t_spell ai_get_best_spell( t_hero const* hero, t_creature_array const* array, int& spell_damage );

float ai_get_spell_damage( t_spell spell, t_hero const* hero );

float ai_give_artifact_to_army( t_creature_array& array, t_artifact const& artifact );
float ai_value_of_giving_artifact_to_army( t_creature_array& array, t_artifact const& artifact );

bool ai_is_hero_ranged( t_hero const* hero );

float ai_summed_primary_skill_value( float cost, bool secular, t_creature_array const* array, t_single_use_object const* object = NULL );
float ai_summed_skill_value( float cost, t_skill_type type_low, t_skill_type type_high, t_creature_array const* array );

float ai_value_of_additional_hit_points( float current_hit_points, float additional_hit_points, float current_value );
float ai_value_of_additional_hit_points( t_creature_stack const* stack, int amount );
float ai_value_of_additional_damage( t_hero const* hero, int damage_adjustment, t_offense_type type );
float ai_value_of_additional_damage( t_creature_stack const* stack, bool ranged, int low, int high );
float ai_value_of_additional_damage( t_creature_stack const* stack, bool ranged, int damage_adjustment );
float ai_value_of_additional_damage( t_creature_stack const* stack, int damage_adjustment );
float ai_value_of_additional_damage( t_creature_stack const* stack, int low, int high );

float ai_value_of_additional_move_speed( t_creature_stack const* stack, int amount );
float ai_value_of_additional_move_speed( t_creature_array const* array, int amount );
float ai_value_of_additional_speed( t_creature_stack const* stack, int amount );
float ai_value_of_additional_speed( t_creature_array const* array, int amount );
float ai_value_of_additional_spell_points( t_hero const* hero, int amount );

float ai_value_of_artifact( t_artifact_value_query& params );
float ai_value_of_artifact_simple( t_creature_array const& army, t_artifact_type artifact );
float ai_value_of_artifact_complex( t_creature_array const& array, t_artifact const& artifact );

float ai_value_of_abstract_artifact( t_creature_array const& army, t_artifact_type artifact);

float ai_value_of_generic_damage_spell( t_hero const* hero, t_spell spell, float multiplier = 1.0f);

float ai_value_of_generic_spell( t_hero const* hero, t_creature_array const* array, t_town_type alignment, int level );

float ai_value_of_skill_increase(t_hero const* hero, t_skill skill, t_creature_array const* array, bool include_related_skills = true);
float ai_value_of_skill_increase_minus_cost(t_hero const* hero, t_skill skill, int cost, t_creature_array const* array, bool include_related_skills = true);

float ai_value_of_luck_change( t_creature_array const& array, t_qualified_adv_object_type const& type, int change );
float ai_value_of_morale_change( t_creature_array const& array,  t_qualified_adv_object_type const& type, int change );

float ai_value_of_spell( t_hero const* hero, t_spell spell, t_creature_array const* array, bool ignore_mana_and_skills = false);

float ai_value_of_xp( t_creature_array const* army, int points );
float ai_value_of_xp_for_army( t_creature_array const* army, int points );

bool ai_wants_primary_skill( t_hero const* hero, t_skill_type skill, t_creature_array const* array );

int get_player_number( t_creature_array const& array );

bool player_can_afford( t_creature_array const* array, int amount );

extern const float k_ai_creature_value_modifier;

// Essentially, the number of days of mine ownership to add into the value of the mine.
extern const int k_ai_mine_value_multiplier;  

#endif
